<?php	
	echo '<span class="heading">Profile</span>';
	echo '<br />';
	
	if($edit == true){
		echo form_open('profile/'.$profile['fb_id'], array('id' => 'profile-form'));
	}
	
	echo '<div class="container">';
		echo '<div id="facebook-holder">';
			echo '<div id="facebook-pic">';
				echo '<a href="https://www.facebook.com/'. $profile['fb_id']. '" target="_blank"><span class="get-fb-pic-large">'. $profile['fb_id'] .'</span></a>';
			echo '</div>';
			echo '<div id="facebook-details">';
				echo '<a href="https://www.facebook.com/' . $profile['fb_id'] . '" target="_blank"><span class="get-fb-name large-text">' . $profile['fb_id'] . '</span></a><br />';
				echo '<br />';
				echo '<span class="medium-text">Email: ' . $profile['email'] . '</span><br />';
				echo '<br />';
				
				if($edit == true){
					echo form_label("About Me: ", "description", array('class' => 'normal-text')) . '<br />';
					$attribute = array(
						'name'  => 'description',
						'id'    => 'description',
						'value' => $profile['description'],
						'placeholder' => 'About Myself',
						'rows' => 3,
						'cols' => 60,
					);
					echo form_textarea($attribute) . '<br /><br />';
				}
				else{
					echo '<label class="normal-text">About Me: </label><br />';
					echo '<div class="normal-text" id="other_information">' .$profile['description'] . '</div><br /><br />';
				}
				
				echo '<span class="normal-text">Successful Offers: ' . $successful_offers . '&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSuccessful Requests: ' . $successful_requests . '</span>';
			echo '</div>';
			echo '<div style="clear: both;"></div>';
		echo '</div>';

		echo '<br />';
		echo '<hr />';	
		echo '<span class="subheading">Email Preferences</span><br /><br />';
		
		echo '<div id="preferences-holder">';
			echo '<div id="preferences-left">';
				echo '<span class="medium-text">Send me an email...</span><br />';
				$email_frequency_options = array(
					0 => 'None',
					1 => 'Daily',
					3 => 'Every 3 days',
					7 => 'Weekly',
					14 => 'Fortnightly',
				);
				foreach($email_frequency_options AS $value=>$name){
					if ($preferences['email_frequency'] == $value) {
						echo '<input type="radio" name="email_frequency" value="' . $value .'" checked="checked" />' . form_label($name, $name) . '<br />' ;
					} else { 
						echo '<input type="radio" name="email_frequency" value="' . $value .'" />' . form_label($name, $name) . '<br />' ;
					}
				}
			echo '</div>';
			echo '<div id="preferences-right">';
				echo '<span class="medium-text">To inform me when there are...</span><br />';
				$email_details_options = array(
					NEW_OFFERS => NEW_OFFERS,
					NEW_REQUESTS => NEW_REQUESTS,
					NEW_COMMENTS => NEW_COMMENTS,
					NEW_NOTIFICATIONS => NEW_NOTIFICATIONS,
				);
				foreach($email_details_options AS $value){
					if ($preferences['email_details'][$value] == true) {
						echo '<input type="checkbox" name="email_details" value="' . $value .'" checked="checked" />' . form_label($value, $value) . '<br />' ;
					} else { 
						echo '<input type="checkbox" name="email_details" value="' . $value .'" />' . form_label($value, $value) . '<br />' ;
					}
				}
			echo '</div>';
			echo '<div style="clear: both;"></div>';
		echo '</div>';
		echo '<div id="submit-holder">';
			echo form_submit('submit', 'Update Profile');
		echo '</div>';
	echo '</div>';

	if($edit == true){
		echo form_close();
	}
	?>